<!--popup start-->
<div id="pop_user_add">
	<div class="popup_bg"></div>
	<iframe class="popup_cover"></iframe>
	<div class="popup_box center_fix">
		<div class="popup_box_t"></div>
		<div class="popup_box_c">
			<h3 class="popup_box_title">发微博</h3>
			<div class="post_box">
				{if !$info}
				<ul class="post_box_select_user clearfix">
				  <li><a href="#" action-data="{$weibo_info.id}" class="select"><img src="{$weibo_info.profile_image_url}" width="34" height="34"></a></li>
				  {foreach $accounts as $val}
				  <li><a href="#" action-data="{$val.id}"><img src="{$val.profile_image_url}" width="34" height="34"></a></li>
				  {/foreach}
				</ul>
				{/if}
				<div class="post_box_input_box_t"><span class="num">您还可以输入<em>140</em>字</span>微博内容</div>
				<div class="post_box_input_box">
					<input type="hidden" name="hid" value="{$info.id}">
					<textarea id="tweet_content">{$info.content}</textarea>
					<div>
						<label class="mr20">
							<input type="radio" name="send_mod" value="0" {if !$info} checked {/if}/>
							普通发布</label>
						<label>
							<input type="radio" name="send_mod" value="1" {if $info} checked {/if}>
							定时发送</label>
					</div>
				</div>
				<div class="clearfix pt20" {if !$info} style="display:none" {/if}>
					<div class="calendar post-calendar hasDatepicker" id="post-calendar">
						<div class="ui-datepicker-inline ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
							<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all"><a title="&lt;上月" class="ui-datepicker-prev ui-corner-all ui-state-disabled"><span class="ui-icon ui-icon-circle-triangle-w">&lt;上月</span></a><a title="下月&gt;" class="ui-datepicker-next ui-corner-all"><span class="ui-icon ui-icon-circle-triangle-e">下月&gt;</span></a>
								<div class="ui-datepicker-title"><span class="ui-datepicker-year">2011</span>年&nbsp;<span class="ui-datepicker-month">九月</span></div>
							</div>
							<table class="ui-datepicker-calendar">
								<thead>
									<tr>
										<th><span title="星期一">一</span></th>
										<th><span title="星期二">二</span></th>
										<th><span title="星期三">三</span></th>
										<th><span title="星期四">四</span></th>
										<th><span title="星期五">五</span></th>
										<th class=""><span title="星期六">六</span></th>
										<th class=""><span title="星期日">日</span></th>
									</tr>
								</thead>
								<tbody id="pick_date">
									
								</tbody>
							</table>
						</div>
					</div>
					<div class="set_time_box">
						{if $time_l}
								<div class="set_time_box_title">最近使用时间点</div>
								<p class="lh24">这里是您最近使用过的时间，方便您来进行添加</p>
								<div class="time clearfix time_pick">
									{foreach $time_l as $val}
										<a href="javascript://">{$val}</a>
									{/foreach}
								</div>
						{/if}
						<div class="set_time_box_title">自定义时间点</div>
						<p class="lh24">您可以根据您的需要添加适合您的时间点</p>
						<div class="mt10">自定义时间：
							<select name="time_h">
							{for $i=1; $i<=24; $i++}
								<option value="{$i}" 
									{if $info}
										{if $i==date('H', $info.send_time)} selected {/if}
									{else}
										{if date('H', time())==$i} selected {/if}
									{/if}>
								{$i}</option>
							{/for}
							</select>：
							<select name="time_i">
								{for $i=0; $i < 60; $i++}
									{if $i < 10}
									<option value="{$i}" {if $info}
															{if $i==date('i', $info.send_time)} selected {/if}
														{else}
															{if date('i', time())==$i} selected {/if}
														{/if}>0{$i}</option>
									{else}
									<option value="{$i}" {if $info}
															{if $i==date('i', $info.send_time)} selected {/if}
														{else}
															{if date('i', time())==$i} selected {/if}
														{/if}>{$i}</option>
									{/if}
								{/for}
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="popup_box_btn">
				<div class="post_btn"> <a href="#" class="ico1">表情</a> <a href="#" class="ico5">话题</a>{include file='lib/upload_pic.html'}
					<div class="post_win" style="left:-30px;display:none">
						<div class="post_win_t"></div>
						<a href="#" class="close">关闭</a>
						<div class="post_win_tab clearfix"><a href="#" class="current loding">loading...</a></div>
					</div>
				</div>
				<a href="#" class="btn4">发布</a><a href="#" class="btn2">取消</a></div>
		</div>
		<div class="popup_box_b"></div>
	</div>
</div>
<!--popup end-->
<script type="text/javascript" charset="utf-8">
$('.post_box_select_user a').click(function(){
  if ($(this).hasClass('select')) {
    $(this).removeClass('select');
  } else {
    $(this).addClass('select');
  }

  return false;
});

$('input[name=send_mod]').click(function(){
  if (this.value == 1) {
    $(this).parents('.post_box_input_box').next().show();
  } else {
    $(this).parents('.post_box_input_box').next().hide();
    
  }
});

$('.time_pick > a').click(function(){
	var data = $(this).html();
	data = data.split(':');
	$('select[name=time_h] option[value='+data[0]+']').attr('selected','selected');
	$('select[name=time_i] option[value='+parseInt(data[1])+']').attr('selected','selected');
});




	var p_date = new Date();

	var get_calendar_year = p_date.getFullYear();
	var get_calendar_month = p_date.getMonth()+1;
	var sys_day = p_date.getDate();
	var sys_year = get_calendar_year;
	var sys_month = get_calendar_month;
	var click_num_next = 0;
	{if $info}
		var pick_day = {date('d',$info.send_time)};
		var pick_year = {date('Y',$info.send_time)};
		var pick_month = {date('m',$info.send_time)};
		click_num_next = ((pick_year-get_calendar_year)*12)-(12-pick_month)+(12-sys_month);
		get_calendar_month = pick_month;
		get_calendar_year = pick_year;
		
	{else}
		var pick_day = sys_day;
		var pick_year = sys_year;
		var pick_month = sys_month;
	{/if}

	
	$('.ui-datepicker-prev').click(function(){
		if (click_num_next!=0) {
			click_num_next--;
			get_calendar('prev');
		};
	});
	$('.ui-datepicker-next').click(function(){
		click_num_next++;
		get_calendar('next');
	});
	
	$('.ui-state-default > a').live('click', function(){
		pick_day = $(this).html();
		pick_year = get_calendar_year;
		pick_month = get_calendar_month;
		$('.ui-state-default > a').removeClass('ui-state-active');
		$(this).addClass('ui-state-active');
	});
	

	get_calendar();
	function get_calendar (action) {
		if (action == 'next') {
			get_calendar_month++;
		}else if(action == 'prev'){
			get_calendar_month--;
		};
		if (get_calendar_month < 1) {
			get_calendar_year--;
			get_calendar_month = 12
		}else if(get_calendar_month > 12){
			get_calendar_year++;
			get_calendar_month = 1;
		};
		
		var days_help = new Date();
		days_help.setFullYear(get_calendar_year);
		days_help.setMonth(get_calendar_month);
		days_help.setDate(0);
		var get_calendar_month_days = days_help.getDate();//当月的天数

		var week_help = new Date(get_calendar_year+"/"+get_calendar_month+"/1");
		var get_calendar_month_week = week_help.getDay();//当前月第一天的星期
		if (get_calendar_month_week==0) {
			get_calendar_month_week = 7;
		};

		// return {
		// 		days : get_calendar_month_days,
		// 		week : get_calendar_month_week,
		// 		now_year : get_calendar_year,
		// 		now_month : get_calendar_month
		// 	};
		view_date(get_calendar_month_days, get_calendar_month_week, get_calendar_year, get_calendar_month);

	};
	
	function view_date (days, week, now_year, now_month) {
		var html = ' ';
		var ii = week;
		html += '<tr>';
		for (var i=1; i < week; i++) {
			html += '<td class="ui-state-disabled">&nbsp;</td>';
		};
		for (var i=1; i <= days; i++) { 
			if (!(ii%7)) {
    			if (i==pick_day && now_month==pick_month && now_year==pick_year) {
    				html += '<td class="ui-datepicker-current-day"><span class="ui-state-default"><a href="javascript://">'+i+'</a></span></td></tr><tr>';
    			}else if(i<sys_day  && now_month==sys_month && now_year==sys_year){
    				html += '<td class="ui-state-disabled "><span>'+i+'</span></td></tr><tr>';
    			}else{
    				html += '<td class=""><span class="ui-state-default"><a href="javascript://">'+i+'</a></span></td></tr><tr>';
    			}
		    } else{
    				if (i==pick_day && now_month==pick_month && now_year==pick_year) {
    					html += '<td class="ui-datepicker-current-day"><span class="ui-state-default"><a href="javascript://" class="ui-state-active">'+i+'</a></span></td>';
    				}else if(i<sys_day && now_month==sys_month && now_year==sys_year){
    					html += '<td class="ui-state-disabled "><span>'+i+'</span></td>';
    				}else{
    					html += '<td class=""><span class="ui-state-default"><a href="javascript://">'+i+'</a></span></td>';
    				}
			}
			ii++;
		}
		var t = 7 - ((ii-1)%7);
		if (t != 7) {
  		for (var i=0; i < t; i++) {
  			html += '<td class="ui-state-disabled">&nbsp;</td>';
  		}
		}
		
		html += '/<tr>';
		
		$('.ui-datepicker-year').html(now_year);
		$('.ui-datepicker-month').html(now_month+'月');
		$('#pick_date').html(html);
		
	};
	
</script>
